package com.conf;

import java.util.ArrayList;

public enum MenuEnum {

	app_start("sh startNoLog.sh", "JMenuItem", "服务启动", "01", "", "app"), 
	app_stop("sh stopNoLog.sh", "JMenuItem", "服务停止", "02", "", "app"), 
	step_batch("", "JMenu", "单步执行", "03", "", ""),
	oracle_batch("sh /u01/test.sh", "JMenuItem", "数据加载", "0301", "03", "oracle"), 
	app_batch("sh batch/bin/batch.sh", "JMenuItem", "数据加工", "0302", "03", "app"), 
	oracle_date("sh /u01/tongbu.sh", "JMenuItem", "日期同步", "0303", "03", "oracle"), 
	all_batch("", "JMenuItem", "批量执行", "04", "", ""),
	oracle_dir("sh a.sh", "JMenuItem", "查看数据文件信息", "04", "", "oracle");
	
	public String command;
	public String type;
	public String name;
	public String id;
	public String parent;
	public String machine;
	
	private MenuEnum() {
		this.id = "";
		this.name = "";
		this.type = "";
		this.parent = "";
		this.machine = "";
		this.command = "";
	}
	private MenuEnum(String id, String name, String type, String parent) {
		this();
		this.id = id;
		this.name = name;
		this.type = type;
		this.parent = parent;
	}
	
	private MenuEnum(String id, String name) {
		this();
		this.id = id;
		this.name = name;
	}
	
	private MenuEnum(String command, String type, String name, 
			String id, String parent, String machine) {
		this.command = command;
		this.type = type;
		this.name = name; 
		this.id = id;
		this.parent = parent;
		this.machine = machine;
	}
	
	public static ArrayList<MenuEnum> getEnums(String parent) {
		ArrayList<MenuEnum> list = new ArrayList<MenuEnum>();
		for (MenuEnum e : values()) {
			if (parent == null) {
				if (e.parent == null) {
					list.add(e);
				}
			} else {
				if (parent.equals(e.parent)) {
					list.add(e);
				}
			}
		}
		return list;
	}
	
	public String getCommand() {
		return this.command;
	}
}
